#include <iostream>
#include <limits>
#include <vector>
using namespace std;

const int kMaxForbidenNumber = 1010;

class Frac {
  long long a_, b_;

  void Cancelling() {
    long long u = a_, v = b_;

    for (long long c = u % v; c; c = u % v) {
      u = v;
      v = c;
    }
    a_ /= v;
    b_ /= v;
  }

 public:
  Frac(long long a, long long b) {
    this->a_ = a;
    this->b_ = b;
  }

  bool operator<=(const Frac &other) const {
    return a_ * other.b_ <= b_ * other.a_;
  }

  bool operator==(const Frac &other) const {
    return a_ * other.b_ == b_ * other.a_;
  }

  Frac operator+(const Frac &other) const {
    Frac ret(a_ * other.b_ + b_ * other.a_, b_ * other.b_);

    ret.Cancelling();
    return ret;
  }

  Frac operator-(const Frac &other) const {
    Frac ret(a_ * other.b_ - b_ * other.a_, b_ * other.b_);

    ret.Cancelling();
    return ret;
  }

  long long GetMinD() {
    return (b_ + a_ - 1) / a_;
  }
};

long long max_d;
vector<long long> ans;
vector<long long> now;
bool frobiden[kMaxForbidenNumber];

void DFS(int dep, Frac sum, const Frac &tar, long long last_d) {
  if (dep == 0) {
    if (sum == tar) {
      bool renew = ans.empty();

      for (int i = ans.size() - 1; !renew && i >= 0; i--) {
        if (ans[i] != now[i]) {
          renew = ans[i] > now[i];
          break;
        }
      }
      if (renew) {
        ans = now;
        max_d = last_d;
      }
    }
    return;
  }

  Frac rest = tar - sum;
  for (long long d = max(last_d + 1, rest.GetMinD()); d <= max_d && rest <= Frac(dep, d); d++) {
    if (d < kMaxForbidenNumber && frobiden[d]) {
      continue;
    }
    now.emplace_back(d);
    DFS(dep - 1, sum + Frac(1, d), tar, d);
    now.pop_back();
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  int T;

  cin >> T;
  for (int no = 1; no <= T; no++) {
    int a, b, k;

    cin >> a >> b >> k;
    fill(frobiden, frobiden + kMaxForbidenNumber, false);
    for (int i = 0; i < k; i++) {
      int f;
      cin >> f;
      frobiden[f] = true;
    }

    ans.clear();
    now.clear();
    Frac tar(a, b);
    for (int max_depth = 2;; max_depth++) {
      max_d = numeric_limits<long long>::max();
      DFS(max_depth, Frac(0, 1), tar, 1);
      if (!ans.empty()) {
        cout << "Case " << no << ": " << a << "/" << b << "=";
        for (int i = 0; i < max_depth; i++) {
          if (i) {
            cout << "+";
          }
          cout << "1/" << ans[i];
        }
        cout << endl;
        break;
      }
    }
  }
  return 0;
}